package com.ls.cor.impl;

import java.util.ArrayList;
import java.util.List;

import com.ls.cor.itf.Filter;
import com.ls.cor.itf.FilterChain;

public class AppFilterChain implements FilterChain{
	private List<Filter> filters;
	private int pos;//当前filter的位置
	private int n;//Filter的总数
	
	public AppFilterChain(){
		filters = new ArrayList<Filter>();
		pos=0;
		n=0;
	}
	public void doFilter(List<String> param) {
		Filter f ;
		while(pos<n){
			f=filters.get(pos++);
			f.doFilter(param, this);
			return;
		}
		param.add("In the last inner chain");
	}
	public List<Filter> getFilters() {
		return filters;
	}
	
	public void setFilters(List<Filter> filters) {
		this.filters = filters;
	}
	
	public void addFilter(Filter filter){
		filters.add(filter);
		n++;
	}
	
}
